from django.shortcuts import render
from django.http import HttpResponse, HttpResponseRedirect, JsonResponse
from common.mymako import render_mako_context
from wechat_sdk import WechatBasic
from wechatpy.utils import check_signature
from wechatpy.exceptions import InvalidSignatureException
from wechatpy import parse_message

# Create your views here.
def MP_verify_c8pXGLcqidjGofw4(request):
    return HttpResponse('c8pXGLcqidjGofw4')

def wechat_auth(request):
    return JsonResponse({'content':'wechat_auth'})

def company_info(request):
    return render_mako_context(request, 'TengweiTechnologyHrxt.html', {})
    #return JsonResponse({'content':'company_info'})

def simple_case(request):
    return render_mako_context(request, 'TengweiTechnologyHrxt.html', {})
    #return JsonResponse({'content':'simple_case'})

def new_product(request):                                           
    #return HttpResponseRedirect('https://shop106047239.taobao.com')
    return render_mako_context(request, 'TengweiTechnologyHrxt.html', {})
    #return JsonResponse({'content':'new_product'})

def taobao_new_prouct(request):                                           
    return render_mako_context(request, 'TengweiTechnologyHrxt.html', {})
    #return JsonResponse({'content':'taobao_new_prouct'})

def app_download(request):                                           
    return HttpResponseRedirect('http://fir.im/e8c3')
   # return render_mako_context(request, 'TengweiTechnologyHrxt.html', {})
    #return JsonResponse({'content':'app_download'})

def contact_us(request):                                           
    return render_mako_context(request, 'TengweiTechnologyHrxt.html', {})
    #return JsonResponse({'content':'contact_us'})

def service_support(request):                                           
    return render_mako_context(request, 'TengweiTechnologyHrxt.html', {})
    #return JsonResponse({'content':'service_support'})

def wechat_check(request):                                           
    token="robotLock"
    signature = request.GET.get('signature')
    timestamp = request.GET.get('timestamp')
    nonce =request.GET.get('nonce')
    wechat = WechatBasic(token=token)
    if wechat.check_signature(signature=signature, timestamp=timestamp, nonce=nonce):
         return HttpResponse('wechat_check success')
    return JsonResponse({'content':'wechat_check fail'})

